<?php

// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');

// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
$cfg = array(
	'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
	'name'=>Yii::t('label','Kiếm thế 247'),



	'language'=>isset($_GET['l']) ? $_GET['l'] : 'vi',

	// preloading 'log' component
//	'preload'=>array('log','bootstrap_v2','bootstrap','bkui_v2'),
	'preload'=>array('log','bootstrap'),

	// autoloading model and component classes
	'import'=>array(
		'application.models.*',
		'application.models.api.*',
		'application.models.form.*',
		'application.components.*',
		'ext.common.RESTful.*',
	),

	'modules'=>array(
		// uncomment the following to enable the Gii tool

		'gii'=>array(
			'class'=>'system.gii.GiiModule',
			'password'=>'123',
		 	#If removed, Gii defaults to localhost only. Edit carefully to taste.
			'ipFilters'=>array('127.0.0.1','::1'),
			'generatorPaths'=>array(
	            'bootstrap_v2.gii', // since 0.9.1
	        ),
		),

		'hq' => array(
			'class' => 'application.modules.hq.HqModule',

			'controllerMap'=>array(
				'yiiLog'=>array(
					'class'=>'ext.common.YiiLogViewerController.YiiLogViewerController',
				),

				'coreRestApiLog'=>array(
					'class'=>'ext.common.RestApiLog.controller.RestApiLogController',
					'logModelClass'=>'CoreRestApiLog',
				),
				'calledRestApiLog'=>array(
					'class'=>'ext.common.RestApiLog.controller.RestApiLogController',
					'logModelClass'=>'RestServerApiLog',
				),
				'registry'=>'ext.common.registry.controllers.RegistryController',
//				'httpUser'=>'ext.common.HttpAuth.controller.HttpUserController',
				'httpUser'=>'ext.self.httpAuthenExt.controller.HttpUserController',
			),

			'modules'=>array(
				'user'=>array(
					'class'=>'ext.Hq.openIDUserModule.OpenIdUserModule',

					'roles'=>array('ADMIN','EDITOR','BUSSINESS'),

					'userComponentName'=>'hqUser',
				),
			),

			'components'=>array(
				'bootstrap'=>array(
                	'class'=>'ext.common.bootstrap_v2.components.Bootstrap',
                	'responsiveCss'=>true,
                	'yiiCss'=>true,
				),
			),
		),
	),

	// application components
	'components'=>array(
		'request' => array(
//	        'class' => 'application.components.HttpRequest',
//	        'enableCsrfValidation' => true,
	        'baseUrl'=>HOME_URL,
	    ),
	    'ExportExcel'=>array(
	    	'class'=>'application.components.ExportExcelComponent'
	    ),

		'bkui'=>array(
        	'class'=>'ext.common.bkui.BKUIComponent',
        	'debug'=>defined('YII_DEBUG') && YII_DEBUG,
//            'globalBarViewFile'=>'bkui.layouts._global_bar',
    	),
    	'bkui_v2'=>array(
			'class'=>'ext.common.bkui_v2.BKUIComponentV2',
			'debug'=>defined('YII_DEBUG') && YII_DEBUG,
		),
    	'bootstrap_v2'=>array(
	        'class'=>'ext.common.bootstrap_v2.components.Bootstrap', // assuming you extracted bootstrap under extensions
	    ),
	    'bootstrap'=>array(
	        'class'=>'ext.common.bootstrap_v2.components.Bootstrap', // assuming you extracted bootstrap under extensions
	    ),

		'session' => array (
			'timeout' => 86400,
		),

		'registry'=>array(
			'class'=>'ext.common.registry.RegistryComponent',
		),

		'sslHttpUser'=>array(
			'class'=>'ext.common.HttpAuth.SslHttpUserComponent',
		),

//		'user'=>array(
			// enable cookie-based authentication
//			'class' => 'ext.common.UserLoginToken.BKWebUser',
//			'allowAutoLogin'=>true,
//		),
		'httpUser'=>array(
			'class'=>'ext.self.httpAuthenExt.HttpUserComponent',
		),

		'hqUser'=>array(
			'class'=>'ext.Hq.HqUserComponent',
			'allowAutoLogin'=>true,
			'loginUrl'=>array('/hq/user/signIn'),
		),

		'cache'=>array(
			'class'=>'CFileCache',
		),

		'assetManager'	=>	array(
			'basePath'	=>	HOME_PATH.'/assets/',
			'baseUrl'	=>	HOME_URL.'/assets/',
		),

		// uncomment the following to enable URLs in path-format
		'urlManager'=>array(
			'class'=>'ext.common.BKUrlManager.BKUrlManager',
			'urlFormat'=>'path',
			'showScriptName'=>false,
			'baseUrl'=>HOME_URL,
			'rules'=>array(
//				'gii'=>'hq/gii',
// 				'gii/<_c:\w+>'=>'hq/gii/<_c>',
// 				'gii/<_c:\w+>/<_a:\w+>'=>'hq/gii/<_c>/<_a>',

				'<_c:\w+>/'=>'<_c>/',
				'<_c:\w+>/<_a:\w+>'=>'<_c>/<_a>',
				'<_m:\w+>/<_c:\w+>/<_a:\w+>'=>'<_m>/<_c>/<_a>',
				'<_p1:\w+>/<_p2:\w+>/<_p3:\w+>/<_p4:\w+>'=>'<_p1>/<_p2>/<_p3>/<_p4>',
			),

			'defaultParams'=>array('l'),
		),


		'db'=>array(
			'connectionString' => 'mysql:host=localhost;dbname=jxaccount',
			'emulatePrepare' => true,
			'username' => 'root',
			'password' => '1234',
			'charset' => 'utf8',
			'schemaCachingDuration'=>3600,

//			'connectionString' => 'mysql:host=localhost;dbname=thecao_lab_baokim_vn',
//			'emulatePrepare' => true,
//			'username' => 'thecao_baokim_vn',
//			'password' => 'W9x6XzUFpLw2FrDC',
//			'charset' => 'utf8',
//			'schemaCachingDuration'=>3600,
		),

		//'errorHandler'=>array(
			// use 'site/error' action to display errors
//			#'discardOutput'=>!defined('YII_DEBUG') || !YII_DEBUG,
//		),
		'log'=>array(
			'class'=>'CLogRouter',
			'routes'=>array(

				// uncomment the following to show log messages on web pages
				/*
				array(
					'class'=>'CWebLogRoute',
				),
				*/
			),
		),
        'user'=>array(
//            'class'=>'VatgiaIDUser',
            'allowAutoLogin'=>true,
            'loginUrl'=>array('site/login'),
//            'stateKeyPrefix'=>'__VID_USER_STATE',
            'loginRequiredAjaxResponse' => 'YII_LOGIN_REQUIRED'
        ),
	),

	// application-level parameters that can be accessed
	// using Yii::app()->params['paramName']
	'params'=>array(
		// this is used in contact page
	),
);

#$cfg = CMap::mergeArray($cfg, require dirname(__FILE__).DIRECTORY_SEPARATOR.'hq.module.php');

if (!isset($_GET['nodebug']) && defined('YII_DEBUG') && YII_DEBUG) $cfg = CMap::mergeArray(
	$cfg,
	require dirname(__FILE__).DIRECTORY_SEPARATOR.'debug.php'
);

return $cfg;
